<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\SmsTpl;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class SmsTplController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new SmsTpl(), function (Grid $grid) {
            $grid->model()->orderBy('id', 'desc');
            $grid->column('send_key');
            $grid->column('title');
            $grid->column('sms_body');
            $grid->column('trigger_type','出发类型')->using([1 =>'用户触发', 2 => '系统触发'])->label([
                1 => 'primary',
                2 => 'success',
            ]);;
            $grid->column('created_at');
            $grid->actions(function (Grid\Displayers\Actions $actions){
                $actions->quickEdit();
            });
            $grid->disableRowSelector();
            //禁用新增按钮
            $grid->disableCreateButton();
            // 禁用过滤器按钮
            $grid->disableFilterButton();
            // 禁用批量删除按钮
            $grid->disableBatchDelete();
            // 禁用显示按钮
            $grid->disableViewButton();
            // 去掉删除
            $grid->disableDeleteButton();
            $grid->disableEditButton();
            //显示横向滚动条
            $grid->scrollbarX();
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new SmsTpl(), function (Form $form) {
            $form->display('send_key');
            $form->text('title');
            $form->textarea('sms_body');
            $form->radio('trigger_type','触发类型')->options([1=>"用户触发",2=>"系统触发"]);
        });
    }
}
